#include "common.h"

int			ACTIVATED_NODE_COUNT;	
int			INACTIVATED_NODE_COUNT;
int			COLOR_COUNT;

NodeHead*	g_adjacencyList;
wstring*		g_colors;


wstring stringToWString( const string& str )
{
	if( str == "" )
	{
		return wstring( L"" );
	}
	int size = str.length() + 1;

	wchar_t * buf = new wchar_t[ size ];

	memset( buf, 0, size );
	string curLocal = setlocale( LC_CTYPE, "" );
#ifdef _WIN32
	unsigned tmp;
	mbstowcs_s( &tmp, buf, size, str.c_str(), str.length() );
#else
	mbstowcs( buf, str.c_str(), size );
#endif
	wstring strW( buf );
	delete [] buf;
	setlocale( LC_CTYPE, curLocal.c_str() );
	return strW;
}

string wstringToString( const wstring& wstr )
{
	if (wstr == L"")
	{
		return string("");
	}

	int size = 2 * wstr.length() + 1;
	char* buf = new char[size];
	memset(buf, 0, size);
	string curLocal = setlocale(LC_CTYPE, "");
#ifdef _WIN32
	unsigned tmp;
	wcstombs_s(&tmp, buf, size, wstr.c_str(), 2 * wstr.length());
#else
	wcstombs(buf, wstr.c_str(), size);
#endif
	string strA(buf);
	delete [] buf;

	setlocale(LC_CTYPE, curLocal.c_str());
	return strA;
}
